import QtQuick 2.0
import SvgImage 1.0

Rectangle {
    id: cusErrorPromptTextRoot
    implicitHeight: 30
    color: "transparent"
    visible: false
    property string descrition: "Non"
    property int visibleTime: 5000

    onVisibleChanged: {
        if( visible ) {
            hideErrorTimer.start()
        }
    }

    onDescritionChanged: {
        hideErrorTimer.stop()
        hideErrorTimer.start()
    }

    Rectangle {
        id: errorImageRect
        anchors.left: parent.left
        anchors.verticalCenter: parent.verticalCenter
        implicitWidth: 12
        implicitHeight: 12
        color: "transparent"

        SvgImage {
            id: errorImage
            source: "qrc:/image_res/assets/image_res/tips_error.svg"
            anchors.fill: parent
        }
    }

    CusText {
        id: errorPromptText
        text: descrition
        font.pixelSize: Theme.font_size_13
        color: Theme.error_color
        anchors.left: errorImageRect.right
        anchors.verticalCenter: parent.verticalCenter
        anchors.leftMargin: 5
        wrapMode: Text.WordWrap
    }

    Timer {
        id: hideErrorTimer
        repeat: false
        interval: visibleTime
        running: false
        onTriggered: { stop()
            cusErrorPromptTextRoot.visible = false
        }
    }
}
